function Camera()
{

	this.x = 0;
	this.y = 0;
	this.stopX1 = canvasBuffer.width/4;
	this.stopX2 = this.stopX1 *2;
	this.stopY1 = canvasBuffer.height/4;
	this.stopY2 = this.stopY1 *2;
	this.resize = function(){

			this.stopX1 = canvasBuffer.width/4;
	this.stopX2 = this.stopX1 *2;
	this.stopY1 = canvasBuffer.height/4;
	this.stopY2 = this.stopY1 *2;
	};
}



function State()
{
	this.initialized = false;
	this.timer = 0;
	this.update = function(){};
	this.init = function(){};

}

function Element()
{
	//inherit from this to make point blocks, link boxes, enemies, etc
}

function Box(element, camera)
{

	var bb = element.getBoundingClientRect();

	this.left = bb.left- camera.x; 
	this.top = bb.top- camera.y; 
	this.width = bb.width;
	this.height = bb.height;
	this.right = bb.right - camera.x;
	this.bottom = bb.bottom -camera.y;
	this.ID = element.id; 
	this.rotation = 0;
	this.needsUpdate = true;
	this.href = element.href;
	this.target = element.target;
	this.element = element;
	if(hasClass(element, "point"))
	{
		this.points = 1;
	}
	else
	{
		this.points = 0;
	}


	this.headbutt = function()
	{
		console.log(this.target);
		
		score += this.points;
		var center = this.width/2 + this.left;
		var distanceFromCenter = center - (player.x + player.width/2  );
		var multiplier = 50;
		var ratio = distanceFromCenter / this.width;
		this.rotation = ratio * multiplier;
		this.needsUpdate = true;

		if(hasClass(this.element, "powerup"))
     		{
     			var child = document.getElementById(this.element.getAttribute("data-powerup-id"));
     			triggerPowerup(child);	
				child.onclick = function(e){
				hitLink(this.href, null, this.target);
				}
			}
			else{
		window.setTimeout(hitLink(this.href, null, this.target), 100);
	}
	}

	this.land = function()
	{

	}

	
}


function Video(element, camera)
{
	if(youTubeReady)
	{
		this.videoPlayer = new YT.Player(element.id, {
          height: '390',
          width: '640',
          videoId: 'M7lc1UVf-VE',
          events: {
            // 'onReady': onPlayerReady,
            // 'onStateChange': onPlayerStateChange
          }
        });

		console.log("youtube ready " , this.videoPlayer);
	}
	var bb = element.getBoundingClientRect();

	this.left = bb.left- camera.x; 
	this.top = bb.top- camera.y; 
	this.width = bb.width;
	this.height = bb.height;
	this.right = bb.right - camera.x;
	this.bottom = bb.bottom -camera.y;
	this.ID = element.id; 
	this.rotation = 0;
	this.needsUpdate = true;
	this.href = element.href;
	this.element = element;
	// this.player = new YT.Player(element.id);
	// this.videoPlayer = new YT.Player(element.id);
	// videoPlayer = new YT.Player("video1");
	if(hasClass(element, "point"))
	{
		this.points = 1;
	}
	else
	{
		this.points = 0;
	}


	this.headbutt = function()
	{
		// console.log(this.videoPlayer);
		if(youTubeReady && this.videoPlayer)
		{
			console.log(document.getElementById("video1"));
			document.getElementById("video1").playVideo();
		}
		//console.log(videoPlayer);
		//console.log("headbutt");
		// videoPlayer.playVideo();
		// videoPlayer.playVideo();
		var center = this.width/2 + this.left;
		var distanceFromCenter = center - (player.x + player.width/2  );
		var multiplier = 50;
		var ratio = distanceFromCenter / this.width;
		this.rotation = ratio * multiplier;
		this.needsUpdate = true;
	}

	this.land = function()
	{

	}

	
}